""""
爬虫流程:
1.分析网页
    url
    请求方式
2.发送请求
    向目标页面发送请求，获取对应的响应
3.响应解析
    1.html
    2.JSON
    3.二进制
4.保存数据
    mysql,redis,txt
"""

import urllib.request as ur
import urllib.parse as up

url = "http://httpbin.org/post"

data = {
    'name': "zhangsan",
    'gender': "famel",
    'age': 18,
}

# 将post数据进行编码加密
newPostData = up.urlencode(data)
# 编码二进制
# newPostData = newPostData.encode('utf-8')

r = ur.urlopen(url, data=newPostData)

if __name__ == '__main__':
    print(r.read().decode('utf-8'))
